import { defineStore } from "pinia";
import { type BasicColorSchema, useDark, usePreferredColorScheme } from "@vueuse/core";
import { type Ref } from "vue";

interface AppStore {
  dark: Ref<boolean>
}

const useAppStore = defineStore("app-store", (): AppStore => {
  const preferredColorScheme = usePreferredColorScheme().value as BasicColorSchema;

  const darkMode = useDark({
    selector: "body",
    attribute: "arco-theme",
    initialValue: preferredColorScheme
  });

  return { dark: darkMode };
}, {
  // @ts-expect-error lint check error
  persist: {

  }
});

export default useAppStore;
